import request from '@/request';

export const fetchCreateOrUpdateCarts = function <T, U>(data: T): Promise<U> {
    return request({
        method: 'post',
        url: '/carts/create',
        data,
    });
};

export const fetchCartList = function <U>(): Promise<U> {
    return request({
        method: 'get',
        url: '/carts/list',
    });
};

export const fetchUpdateCart = function <T = any, U = any>(id: string, data: T): Promise<U> {
    return request({
        method: 'post',
        url: '/carts/update/' + id,
        data,
    });
};

export const fetchDeleteCart = function <U>(id: string): Promise<U> {
    return request({
        method: 'delete',
        url: '/carts/delete/' + id,
    });
};

export const fetchMutilUpdateCart = function <T = any, U = any>(data: T): Promise<U> {
    return request({
        method: 'post',
        url: '/carts/mutil_update',
        data,
    });
};
